package com.sys.util;

import com.sys.handle.OnTimeHandler;

import java.util.Timer;
import java.util.TimerTask;

@SuppressWarnings("unused")
public class MyTimerTask extends TimerTask {
    private OnTimeHandler handler;
    private Timer timer;
    private boolean isInterval = false;

    @Override
    public void run() {
        this.handler.timerFunction();
        if (timer != null && !isInterval) {
            timer.cancel();
        }
    }

    void setHandler(OnTimeHandler handler) {
        this.handler = handler;
    }

    void setTimer(Timer timer) {
        this.timer = timer;
    }

    void setInterval(boolean isInterval) {
        this.isInterval = isInterval;
    }
}